home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Code Resources / Jims CDEFs 1.50 / demo Source ƒ / demoButtons.c < prev    next >
Encoding:
Text File  |  1995-10-27  |  1.8 KB  |  82 lines  |  [TEXT/KAHL]

  1. // -----------------------------------------------------------------------------
  2. //    File    : demoButtons.c
  3. //    Date    : June 18, 1995
  4. //    Author    : Jim Stout
  5. //    Purpose    : show use of 'cctb' resource to colorize push buttons
  6. //            :
  7. // -----------------------------------------------------------------------------
  8.  
  9. #include "demoDialog.h"
  10. #include "movableModal.h"
  11.  
  12. extern void demoButtons()
  13. {
  14.     DialogPtr            theDialog;
  15.     short                itemHit,t,i,val;
  16.     Rect                r;
  17.     ControlHandle        h=0,h2=0;
  18.     Boolean                on=true;
  19.  
  20.     theDialog = GetNewDialog(220,0L,(DialogPtr)-1);
  21.     if(theDialog) {
  22.         SetPort(theDialog);    
  23.         
  24.         TextFont(courier);
  25.         TextSize(12);
  26.         ShowWindow(theDialog);
  27.         
  28.         do {
  29.             movableModalDialog(nil,&itemHit);
  30.             switch(itemHit) {
  31.                 case 3:
  32.                     for(i=1;i<=12;i++ ) {
  33.                         if(i == 2 || i == 3)
  34.                             continue;
  35.                         GetDItem(theDialog, i, &t, (Handle *)&h, &r);
  36.                         if(on)
  37.                             HiliteControl(h, 0xFF);
  38.                         else
  39.                             HiliteControl(h, 0);
  40.                     }
  41.                     on = !on;
  42.                     GetDItem(theDialog, 3, &t, (Handle *)&h, &r);
  43.                     if(on)
  44.                         SetControlTitle(h, "\pDisable");
  45.                     else {
  46.                         SetControlTitle(h, "\pEnable");
  47.                         GetDItem(theDialog, 12, &t, (Handle *)&h, &r);
  48.                         SetControlValue(h, 0);
  49.                     }
  50.                 break;
  51.                 case 10:
  52.                 case 11:
  53.                     GetDItem(theDialog, 10, &t, (Handle *)&h, &r);
  54.                     GetDItem(theDialog, 11, &t, (Handle *)&h2, &r);
  55.                     if(itemHit == 10) {
  56.                         SetControlValue(h, 1);
  57.                         SetControlValue(h2, 0);
  58.                     }
  59.                     else {
  60.                         SetControlValue(h, 0);
  61.                         SetControlValue(h2, 1);
  62.                     }
  63.                 break;
  64.                 case 12:
  65.                     GetDItem(theDialog, 12, &t, (Handle *)&h, &r);
  66.                     val = GetControlValue(h);
  67.                     SetControlValue(h, !val);
  68.                     for(i=4;i<=9;i++) {
  69.                         GetDItem(theDialog, i, &t, (Handle *)&h, &r);
  70.                         if(val)
  71.                             HiliteControl(h, 0);
  72.                         else
  73.                             HiliteControl(h, inButton);
  74.                     }
  75.                 break;
  76.             }
  77.         }while(itemHit != 1);
  78.         DisposDialog(theDialog);
  79.     }
  80. }
  81.  
  82.